package com.angle3d.samples;

import com.angle3d.Node;
import com.angle3d.View3D;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class BillboardsActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
        
        //setup screen orientation and full screen mode 
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        
        //create a simple 3D scene
        Node myScene = new SceneFactory().createScene(this);
        
        //create a 3D view
        View3D view = new View3D(this) {        
        
        	@Override
        	public void onSizeChanged(int newW, int newH, int oldW, int oldH) {
        		super.onSizeChanged(newW, newH, oldW, oldH);
		        
        	    //update the perspective parameters of the camera
		        float aspect = newW/(float)newH;//updated aspect ratio
		        float near = 0.05f;//near clip plane distance 
		        float far = 50.0f;//far clip plane distance
		        float fov = 45.0f;//camera field of view (vertical angle)
		        
		        getCamera().setPerspective((float)Math.toRadians(fov), aspect, near, far);   
        	}
        };
        
    	// set the clear (background) color of our view
        view.setClearColor(0.1f, 0.3f, 0.5f, 0f);
        
        //setup the camera position and orientation
        view.getCamera().setLookAt(2, 2, 2,   0, 0, 0,   0, 1, 0);
        
        //set the scene in the view
        view.setScene(myScene);

        //set our 3D view as the view for this activity
        setContentView(view);
    }
    
    @Override
    public void onResume() {
    	super.onResume();
    	
    }
}